<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<div id="app">
    <button v-on:click="click1" >提交</button>
    {{message}}
</div>

<script>
    var app = new Vue({
        // e1: '#app',
        //注意这时l来着
        el: '#app',
        data: {
            baseUrL:"http://localhost:8080",
            url:'/weiRes/registry' ,
            message:null,
        },
        methods: {
            click1: function () {
                axios({
                    method: 'POST',
                    url: this.url,
                    data: {
                         username:"user2",
                         password:"password",
                         open_id:"222",
                         name:"马超",
                         identity:"440823155602172856",
                         houseId:2,
                    },
                    transformRequest: [function (data) {
                        //把data的格式变成Form格式
                        let ret = ''
                        for (let it in data) {
                            ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
                        }
                        return ret
                    }],
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded'
                    }
                }).then((response) => {
                    alert(response.data.status)
                    if (response.data.status== 0) {
                        alert("注册失败")
                        // window.location.href = this.forwardUrl;
                        this.message=response.data.message

                    }

                    if (response.data.status == 1) {
                        alert("注册成功")
                        this.message=response.data.message

                    }
                })
            }
        }

    })
    app.url=app.baseUrL+app.url;

</script>
</body>

</html>